package org.huang.zhen;

import java.util.Random;

public class BlockFactory {
    private static int [][] emptyBlcokMap = new int[0][1];
    /**
     *  #
     *  #
     *  #  #
     */
    private static int [][] Block1 = new int[][]{{1, 0},{1, 0},{1, 1}};
    /**
     *    #
     *  # # #
     *
     */
    private static int [][] Block2 = new int[][]{{0, 1, 0},{1, 1, 1}};
    private static int [][] Block3 = new int[][]{{1, 1},{1, 1}};

    /**
     *    #
     *    #
     *  # #
     */
    private static int [][] Block4 = new int[][]{{0, 1},{0, 1},{1, 1}};
    /**
     *   # #
     *     # #
     */
    private static int [][] Block5 = new int[][]{{1, 1, 0},{0, 1, 1}};
    /**
     *     # #
     *   # #
     */
    private static int [][] Block6 = new int[][]{{0, 1, 1},{1, 1, 0}};
    private static int [][] Block7 = new int[][]{{1, 1, 1, 1}};

    private static int[][][] BlockArray = new int [][][]{Block1, Block2, Block3,Block4, Block5, Block6, Block7};
    public static Block getEmptyBlock() {
        return new Block(emptyBlcokMap);
    }

    public static Block getGeneralBlock() {
        Random r = new Random();
        int blkIndex = r.nextInt(BlockArray.length);
        return new Block(BlockArray[blkIndex]);
    }

    public static Block getGeneralBlcok(int index){
        if (index < 0 || index >= BlockArray.length) {
            index = 0;
        }
        return new Block(BlockArray[index]);
    }


}
